// import './index.scss';
import CONSTANT from '@/common/constants.js';
import http from '@/common/http.js';
import Group from 'vux/src/components/group/index.vue'
import Cell from 'vux/src/components/cell/index.vue'
// import Http from "../../common/http";
export default {
  name: 'donateListDetails',
  components: {Cell, Group},
  data () {
    return {
      index: 0,
      // 信息反馈是否有红点  为''的时候没有  为' '的时候有
      isXinxi: ' ',
      userId: '',
      item: 'item',
      textMoney: '',
      checkOK: true,
      isA: true,
      threshold: 50,
      minmovingdistance: 30,
      // 项目id
      event_id: '',
      oneevent_id: '',
      student_id: '',
      help_id: '',
      // 显示哪一个模块
      pageNoOther: 1,
      pageNoJuankuan: 1,
      lookMore: '查看更多',
      lookMoreJuankuans: '查看更多',
      pageNo: 1,
      pageSize: 5,
      pageSizeN: 1,
      witchShow: 'xiangqing',
      eventAll: {},
      eventOther: [],
      eventJuankuan: [],
      isDoing: '进行中',
      showright: true,

      ifShowtt: true,
      liuyan: '',
      checkOKs: true,
      show: false,
      name: '',
      mobile: '',
      IDNum: '',
      address: '',

      eventL: {},
      showContent: true,
      celltitle: '点击收起'

    }
  },
  mounted () {
    if (this.$emit('ifOpenid')) {
      this.$emit('ifOpenid', this.$route.path)
    }
    this.userId = window.sessionStorage.getItem('userId')
    this.event_id = window.sessionStorage.getItem('event_id')
    if (this.$route.query.id) {
      console.log(this.$route.query.id)
      this.student_id = this.$route.query.id
      this.help_id = this.$route.query.hid
      this.studentMessage()
    } else {
      this.mountedH()
    }
    // this.event_id = window.sessionStorage.getItem('event_id')
  },
  methods: {
    studentMessage () {
      console.log(123)
      http.post(CONSTANT.STUDENT_VIEW, {userId: this.userId, student_id: this.student_id, help_id: this.help_id}, (res) => {
        console.log(res)
        if (res.code == 200) {
          this.eventL = res.obj
          this.mobile = this.eventL.telephone
          this.name = this.eventL.nickname
          this.IDNum = this.eventL.idCard
          this.address = this.eventL.address
          if (this.eventL.sex == 'woman') {
            this.eventL.sex = '女'
          } else if (this.eventL.sex == 'man') {
            this.eventL.sex = '男'
          } else {
            this.eventL.sex = ''
          }
          var names = this.eventL.name
          names = names.split('')  // 将a字符串转换成数组
          names.splice(1, 1, '*') // 将1这个位置的字符，替换成'xxxxx'. 用的是原生js的splice方法。
          names = names.join('')  // 将数组转换成字符串。  完成。
          this.eventL.name = names
        }
      })
    },
    primary () {
      if (this.checkOKs == false) {
        alert('请同意并接受\n《亲青筹用户协议》！')
      } else {
        http.post(CONSTANT.USER_MESSAGE, {userId: this.userId, name: this.name, idCard: this.IDNum, telephone: this.mobile, address: this.address, event_id: this.event_id, content: this.liuyan}, (res) => {
          console.log(res)
        })
        this.$router.push({path: '/payment', query: {money: this.eventL.eventGoalAmount}})
      }
    },
    swipe (e) {
      console.log(e.direction)
      if (this.student_id == '') {
        if (e.direction == 'Right') {
          this.pageNo++
          this.mountedH()
        } else if (e.direction == 'Left') {
          this.pageNo--
          if (this.pageNo <= 0) {
            this.pageNo = 1
            return
          }
          this.mountedH()
        }
      }
    },
    leftBtn () {
      this.pageNo--
      if (this.pageNo <= 0) {
        this.pageNo = 1
        alert('没有更多了')
        return
      }
      this.mountedH()
    },
    rightBtn () {
      this.pageNo++
      this.mountedH()
    },
    mountedH () {
      http.post(CONSTANT.STUDENT_MESSAGE, {userId: this.userId, biunique_id: this.event_id, pageNo: this.pageNo, pageSize: this.pageSizeN}, (res) => {
        console.log(res)
        if (res.code == 200) {
          if (res.errmsg == '没有更多的学生') {
            this.pageNo--
            this.showright = false
            alert('没有更多了')
            return
          }
          this.eventL = res.list[0]
          this.mobile = this.eventL.telephone
          this.name = this.eventL.nickname
          this.IDNum = this.eventL.idCard
          this.address = this.eventL.address
          if (this.eventL.sex == 'woman') {
            this.eventL.sex = '女'
          } else if (this.eventL.sex == 'man') {
            this.eventL.sex = '男'
          } else {
            this.eventL.sex = ''
          }
          var names = this.eventL.name
          names = names.split('')  // 将a字符串转换成数组
          names.splice(1, 1, '*') // 将1这个位置的字符，替换成'xxxxx'. 用的是原生js的splice方法。
          names = names.join('')  // 将数组转换成字符串。  完成。
          this.eventL.name = names
        }
      })
    },
    checkOks (val) {
      console.log(val)
    },
    goPayment () {
      this.show = true
    },
    comeBack () {
      window.history.go(-1)
    }
  }
}
